﻿namespace OsPortal
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.IO;
    using System.Net;
    using System.Text.RegularExpressions;
    using System.Xml;

    public class oRegexHelper
    {
        public static DataTable DocdulieuRSS(string Url)
        {
            DataSet set = new DataSet();
            XmlTextReader reader = new XmlTextReader(Url);
            try
            {
                set.ReadXml(reader);
            }
            catch
            {
            }
            return set.Tables[1];
        }

        public static List<string> getlstImageInContent(string strContent)
        {
            List<string> list = new List<string>();
            string pattern = " src=\"([^\"]*)\"";
            MatchCollection matchs = new Regex(pattern).Matches(strContent);
            for (int i = 0; i < matchs.Count; i++)
            {
                string item = matchs[i].Value.Substring(6);
                item = item.Substring(0, item.Length - 1);
                list.Add(item);
            }
            return list;
        }

        public static string LoadHTML(string link)
        {
            try
            {
                StreamReader reader = new StreamReader(WebRequest.Create(link).GetResponse().GetResponseStream());
                return Regex.Replace(reader.ReadToEnd(), "\t|\r|\n", "");
            }
            catch (Exception)
            {
                return "Lỗi trong qu\x00e1 tr\x00ecnh xử l\x00fd";
            }
        }
    }
}

